import { setGlobal } from '@swda/utils'
//-----------------------------------------------------------------------------
// Window_FuList【炼符列表】
//
// 符咒奇术列表，显示全部标记为符咒的技能。绘制持有相应符咒的数量。数量满时无法炼符。

function Window_FuList() {
    this.initialize.apply(this, arguments);
}

Window_FuList.prototype = Object.create(Window_SkillList.prototype);
Window_FuList.prototype.constructor = Window_FuList;

Window_FuList.prototype.includes = function(item) {
    return item;
};
Window_FuList.prototype.makeItemList = function() {
    if (this._actor) {
        this._data = this._actor.skills().filter(function(item) {
            return item.isFu;
        }, this);
    } else {
        this._data = [];
    }
};

Window_FuList.prototype.isEnabled = function (skill) {
    if (!skill) return false;
    let item = $dataItems[skill.fuItemId];
    if ($gameParty.numItems(item) >= $gameParty.maxItems(item)) return false;
    return true;
};

Window_FuList.prototype.drawItem = function(index) {
    var skill = this._data[index];
    if (skill) {
        var costWidth = this.costWidth();
        var rect = this.itemRect(index);
        rect.width -= this.textPadding();
        this.changePaintOpacity(this.isEnabled(skill));
        this.drawItemName(skill, rect.x, rect.y, rect.width - costWidth);
        this.drawFuNum(skill, rect.x, rect.y, rect.width);
        this.changePaintOpacity(1);
    }
};


Window_FuList.prototype.drawFuNum = function (skill, x, y, width) {
    var numItems = Yanfly.Util.toGroup($gameParty.numItems($dataItems[skill.fuItemId]));
    this.contents.fontSize = Yanfly.Param.ItemQuantitySize;
    // this.drawText('\u00d7' + numItems, x, y, width, 'right');
    this.drawText("持有", x - 32, y, width, 'right')
    this.drawText( numItems, x, y, width, 'right')
    this.resetFontSettings();
};

setGlobal('Window_FuList', Window_FuList)